import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_shensu/common/util/common_utils.dart';
import 'package:flutter_shensu/common/util/navigator_utils.dart';
import 'package:dio/dio.dart';

class WelcomePage extends StatefulWidget {
  static final String sName = '/';

  @override
  _WelcomePageState createState() {
    return _WelcomePageState();
  }
}

class _WelcomePageState extends State<StatefulWidget> {
  bool _hadInit = false;

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();

    if (_hadInit) {
      return;
    }

    _hadInit = true;
    CommonUtils.initStatusBarHeight(context);
    new Future.delayed(const Duration(seconds: 1), () {
      NavigatorUtils.goMainPage(context);
      return true;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Container(
      color: Colors.white,
      child: new Container(
        child: Image(
          image: AssetImage('static/images/splash_bg.png'),
          fit: BoxFit.fill,
        ),
      ),
    );
  }
}
